package com.data.velocitytool;

import com.data.controller.report.ManageController;
import com.data.model.SystemModel;
import com.data.utill.TableField;

import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;

/**
 * Created by silenceholic on 2017/5/12.
 */
public class CommonTools {

    public boolean Compare(String arg1, String arg2) {
        try {
            return Integer.parseInt(arg1) >= Integer.parseInt(arg2);
        } catch (Exception e) {
            return false;
        }
    }

    /**
     * 判断是否是周末
     *
     * @return
     */
    public boolean IsWeekend() {
        return IsWeekend(new Date(System.currentTimeMillis()));
    }

    /**
     * 判断是否是周末
     *
     * @param date
     * @return
     */
    public boolean IsWeekend(Date date) {
        return IsSaturday(date) || IsSunday(date);
    }

    public boolean IsSaturday(Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        return calendar.get(Calendar.DAY_OF_WEEK) == (int) Calendar.SATURDAY;
    }

    public boolean IsSunday(Date date) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(date);
        return calendar.get(Calendar.DAY_OF_WEEK) == (int) Calendar.SUNDAY;
    }

    public boolean HasMail(String mail,String cMail){
        return  org.apache.commons.lang.ArrayUtils.contains(cMail.split(";"), mail);
    }

    public boolean HasMail(String mail,String[] cMail){
        return org.apache.commons.lang.ArrayUtils.contains(cMail, mail);
    }

    /**
     * 将金额数字转换为千分位表现形式
     * @param inputStr
     * @return
     */
    public static String moneyFormat(String inputStr){
        if(inputStr.equals(""))
            return "0.00";
        try {
            NumberFormat formater = NumberFormat.getInstance();
            formater.setMinimumFractionDigits(2); //保留两位小数
            return formater.format(Double.valueOf(inputStr));
        } catch (Exception e) {
            System.out.println(e.getMessage());
            return inputStr;
        }
    }

    /**
     * 翻译协议状态为中文
     * @param state
     * @return
     */
    public static String consignStateToZH(String state){
        return new TableField("state").getName(state);
    }

    /**
     *翻译付款账户类型为中文
     * @param state
     * @return
     */
    public static String dbtrtypeToZH(String state){
        return new TableField("dbtrtype").getName(state);
    }

    /**
     * 翻译账户状态为中文
     * @param state
     * @return
     */
    public static String orgAccountStateToZH(String state){
        return new TableField("orgAccountState").getName(state);
    }

    /**
     * 记账方式
     * @param state
     * @return
     */
    public static String bookmodeToZH(String state){
        return new TableField("bookmode").getName(state);
    }

    /**
     * 将时间格式化显示
     * @param date
     * @return
     */
    public static String datetime(Date date){
        if(date==null){return "";}
        return new SimpleDateFormat("yyyy/MM/dd HH:mm:ss", Locale.getDefault()).format(date).toString();
    }

    /**
     * 收款账户类型
     * @param state
     * @return
     */
    public static String cdtrclassToZH(String state){
        return new TableField("cdtrclass").getName(state);
    }

    /**
     * 机构类型
     * @param state
     * @return
     */
    public static String orgtypeToZH(String state){
        return new TableField("orgtype").getName(state);
    }

    /**
     * 机构允许的业务类型
     * @param state
     * @return
     */
    public static String busiallowToZH(String state){
        return new TableField("busiallow").getName(state);
    }
    /**
     * 机构允许的业务类型
     * @param state
     * @return
     */
    public static String consigntypeToZH(String state){
        return new TableField("consigntype").getName(state);
    }
    /**
     * 是否检查协议
     * @param state
     * @return
     */
    public static String checkflagToZH(String state){
        return new TableField("checkflag").getName(state);
    }

    /**
     * 密押类型
     * @param state
     * @return
     */
    public static String mactypeToZH(String state){
        return new TableField("mactype").getName(state);
    }
    /**
     * 机构接入类型
     * @param state
     * @return
     */
    public static String nodetypeToZH(String state){
        return new TableField("nodetype").getName(state);
    }
    /**
     * 机构服务类型
     * @param state
     * @return
     */
    public static String svctypeToZH(String state){
        return new TableField("svctype").getName(state);
    }
    /**
     * TCP通讯模式
     * @param state
     * @return
     */
    public static String commtypeToZH(String state){
        return new TableField("commtype").getName(state);
    }
    /**
     * 机构状态
     * @param state
     * @return
     */
    public static String orgstatToZH(String state){
        return new TableField("orgstat").getName(state);
    }
    /**
     * 下载模式
     * @param state
     * @return
     */
    public static String downmodeToZH(String state){return new TableField("downmode").getName(state);}
    /**
     * 明细状态
     * @param state
     * @return
     */
    public static String prcstateToZH(String state){return new TableField("prcstate").getName(state);}
    /**
     * 清算状态
     * @param state
     * @return
     */
    public static String clrstateToZH(String state){return new TableField("clrstate").getName(state);}
    /**
     * 退回标识，表示该流水被退回
     * @param state
     * @return
     */
    public static String rejectflagToZH(String state){return new TableField("rejectflag").getName(state);}
    /**
     * 银行级别
     * @param state
     * @return
     */
    public static String banklevelToZH(String state){return new TableField("banklevel").getName(state);}
    /**
     * 银行状态
     * @param state
     * @return
     */
    public static String bankstatToZH(String state){return new TableField("bankstat").getName(state);}
    /**
     * 借贷标志
     * @param state
     * @return
     */
    public static String dcflagToZH(String state){return new TableField("dcflag").getName(state);}
    /**
     * 业务类型
     * @param state
     * @return
     */
    public static String trncodeToZH(String state){return new TableField("trncode").getName(state);}




}
